import pandas as pd

# （1）从这个 CSV 文件中读取数据到 DataFrame
filename = 'exp_1.csv'
df = pd.read_csv(filename)

# （2）对员工按工资降序和年龄升序排序
df_sorted = df.sort_values(by=['Salary', 'Age'], ascending=[False, True])# 指定降序

# （3）选择工资前 50% 的员工记录
num_rows_to_select = int(len(df) * 0.5)  # 四舍五入取整
df_top_half_salary = df_sorted.head(num_rows_to_select)

# （4）输出工资最高和最低的员工的姓名和工资
# 工资最高的员工
max_salary_employee = df_sorted.iloc[0]
print(f"工资最高的员工：{max_salary_employee['Name']}, 工资：{max_salary_employee['Salary']}")

# 工资最低的员工
min_salary_employee = df_sorted.iloc[-1]
print(f"工资最低的员工：{min_salary_employee['Name']}, 工资：{min_salary_employee['Salary']}")